package com.ytjj.qmyx.admin.controller;

import com.ytjj.common.api.CommonResult;
import com.ytjj.qmyx.admin.annotation.OperLog;
import com.ytjj.qmyx.admin.constants.SysLogConstants;
import com.ytjj.qmyx.admin.model.request.HotProductCategoryRequest;
import com.ytjj.qmyx.admin.service.HotProductCategoryService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 *
 *
 * @Version: 1.0
 *
 * 爆品管理-分类
 */
@RestController
@RequestMapping("/hotProductCategory")
public class HotProductCategoryController {

    @Resource
    private HotProductCategoryService hotProductCategoryService;

    @GetMapping("/list")
    @OperLog(operModule = "爆品管理-分类", operDesc = "分类", operType = SysLogConstants.OPERATION_SELECT)
    public CommonResult selectList(HotProductCategoryRequest hotProductCategoryRequest) {
        return CommonResult.success(hotProductCategoryService.selectList(hotProductCategoryRequest));
    }

    @GetMapping("/insert")
    @OperLog(operModule = "爆品管理-分类", operDesc = "新增分类", operType = SysLogConstants.OPERATION_ADD)
    public CommonResult insertHotProductCategory(@RequestParam Integer hotProductId, @RequestParam String name, @RequestParam Integer sort) {
        return CommonResult.success(hotProductCategoryService.insertHotProductCategory(hotProductId, name, sort));
    }

    @GetMapping("/update")
    @OperLog(operModule = "爆品管理-分类", operDesc = "编辑分类", operType = SysLogConstants.OPERATION_UPDATE)
    public CommonResult updateHotProductCategory(@RequestParam String name, @RequestParam Integer categoryId, @RequestParam Integer sort) {
        return CommonResult.success(hotProductCategoryService.updateHotProductCategory(name, categoryId, sort));
    }

    @GetMapping("/removeData")
    @OperLog(operModule = "爆品管理-分类", operDesc = "移除分类", operType = SysLogConstants.OPERATION_DELETE)
    public CommonResult removeData(@RequestParam Integer categoryId) {
        return CommonResult.success(hotProductCategoryService.removeData(categoryId));
    }
}
